/*eVH3rW+a11viP7GAEvLglQ/mQOWUL9o3TccIrZF81OrKmEBrTNAnRkJisQs+A9niKGE3QF1hPnKC
zH+um4a4kQ==*/
import { contractMainTransferPageCode, contractAppcode, contractMainTransferId } from '../constants';
import ampub from 'ampub';
import fa from 'fa';
const { fa_components: { CardLinkToBillUtil: { CardLinkToBill } } } = fa;
const { components: { AMTooltip }, utils } = ampub;
const { msgUtils: { showMessage }, multiLangUtils: { getMultiLangByID } } = utils;

export default function(props) {
    let that = this
	props.createUIDom(
		{
			pagecode: contractMainTransferPageCode,
			appcode: contractAppcode
		},
		function(data) {
			if (data) {
				if (data.template) {
					let meta = data.template;
					meta = modifierMeta.call(this, props, meta);
                    props.meta.addMeta(meta);
                    that.updateDataFn();
				}
			}
		}
	);
}
function modifierMeta(props, meta) {
	//增加超链接
	meta[contractMainTransferId].items = meta[contractMainTransferId].items.map((item, key) => {
		//合同号添加下划线超链接
		if (item.attrcode == 'contract_no') {
			item.render = (text, record, index) => {
				return (
					<div className="simple-table-td">
						<AMTooltip>
							<span
								className="code-detail-link"
								onClick={() => {
									billreview(props, record);
								}}
							>
								{record.contract_no && record.contract_no.value}
							</span>
						</AMTooltip>
					</div>
				);
			};
		}
		return item;
	});
	return meta;
}

//单据追溯
function billreview(props, record) {
	//获取卡片来源 4A3A
	//获取来源主键 bill_code key
	let pk_bill_src = record.pk_contract.value;
	let transi_type = record.transi_type.value;

	if (pk_bill_src) {
		CardLinkToBill.call(this, props, pk_bill_src, transi_type);
	} else {
		/*国际化处理：该单据的来源单据号错误*/
		showMessage(props, { content: getMultiLangByID('201201504A-000021'), color: 'warning' });
	}
}

/*eVH3rW+a11viP7GAEvLglQ/mQOWUL9o3TccIrZF81OrKmEBrTNAnRkJisQs+A9niKGE3QF1hPnKC
zH+um4a4kQ==*/